package db

import (
	"fmt"
	"strings"
)

func PostMainProblem(ptitle string, pdescription string, poster string, answercode string) {
	_, err := Dd.Exec("INSERT INTO problems(title,content,poster,answercode) VALUES(?,?,?,?)", ptitle, pdescription, poster, answercode)
	if err != nil {
		fmt.Println("PostMainProblem", err)
	}

}

func PostProblemInputArgs(ptitle string, rowArgsString string) {
	args := strings.Split(rowArgsString, ";")
	for i := range args {
		typeValue := strings.Split(args[i], ":")

		_, err := Dd.Exec("INSERT INTO args(problemTitle,argname,itsorder,argtype) VALUES(?,?,?,?)", ptitle, typeValue[0], (i + 1), typeValue[1])
		if err != nil {
			fmt.Println("PostProblemInputArgs", err)
		}
	}
}
